CREATE TABLE VPI.EXTRACT_BATCH_PROGRESS
(
	BATCH_ID		NUMBER(9)		NOT NULL,
	CREATED_TIME	TIMESTAMP(3)	DEFAULT SYSTIMESTAMP	NOT NULL,
	TOTAL_STEPS		NUMBER(5)		DEFAULT 1				NOT NULL,
	LAST_LOG_TIME	TIMESTAMP(3)	DEFAULT SYSTIMESTAMP	NOT NULL,
	PROGRESS_STEP	NUMBER(5)		DEFAULT 0				NOT NULL,
	PROGRESS_DESC	VARCHAR2(128),

	CONSTRAINT PK_EXTRACT_BATCH_PROGRESS PRIMARY KEY (BATCH_ID),
	CONSTRAINT FK_EXTRACT_BATCH_PROGRESS FOREIGN KEY (BATCH_ID) REFERENCES VPI.EXTRACT_BATCH (BATCH_ID) ON DELETE CASCADE
);

COMMENT ON TABLE VPI.EXTRACT_BATCH_PROGRESS
	IS 'The latest progress of a batch, can be used for polling the status of a running batch by UI.';

COMMENT ON COLUMN VPI.EXTRACT_BATCH_PROGRESS.CREATED_TIME
	IS 'LAST_LOG_TIME - CREATED_TIME = SPENT_TIME';
COMMENT ON COLUMN VPI.EXTRACT_BATCH_PROGRESS.TOTAL_STEPS
	IS 'How many steps the batch will totally have?';
COMMENT ON COLUMN VPI.EXTRACT_BATCH_PROGRESS.LAST_LOG_TIME
	IS 'The latest log time.';
COMMENT ON COLUMN VPI.EXTRACT_BATCH_PROGRESS.PROGRESS_STEP
	IS 'Current processing step, UI can use this value to estimate the % of progress (PROGRESS_STEP/TOTAL_STEPS).';
COMMENT ON COLUMN VPI.EXTRACT_BATCH_PROGRESS.PROGRESS_DESC
	IS 'What''s current step doing?';
